// components/dialog-popup/index.js
Component({
  properties: {
    title: {
      type: String,
      value: ''
    },
    content: {
      type: String,
      value: ''
    }
  },
  data: {
    visible: false,
    animationData: {}
  },
  methods: {
    show(){
      const animation1 = wx.createAnimation({
        timingFunction: 'step-start'
      });
      // 初始状态：缩小到0.5倍
      animation1.scale(0.5, 0.5).step();
      this.setData({
        animationData: animation1.export()
      });
      this.setData({ visible: true });
      const context = this;
      setTimeout(function(){
        const animation = wx.createAnimation({
          duration: 250,
          timingFunction: 'ease-in-out'
        });
        // 最终状态：放大到1倍（即100%）
        animation.scale(1, 1).step();
        context.setData({
          animationData: animation.export()
        });
      }, 100);
    },
    onCancel() {
      const context = this;
      const animation = wx.createAnimation({
        duration: 250,
        timingFunction: 'ease-in-out'
      });
      // 最终状态：放大到1倍（即100%）
      animation.scale(0.5, 0.5).step();
      context.setData({
        animationData: animation.export()
      });
      setTimeout(function(){
        context.setData({ visible: false });
      }, 250);
    },
    onConfirm() {
      //定义一个事件，供调用页面触发使用
      this.triggerEvent('ensure', 'hello');
      // this.setData({ visible: false });
    }
  }
});
